package cn.codeforfun.user;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by Administrator on 2016/12/11 0011.
 */
@Repository
public interface UserDao extends JpaRepository<User, Long> {
    /**
     * 通过姓名查询用户
     *
     * @param name
     * @return
     */
    List<User> findByNameLike(String name);

    /**
     * 通过多项条件查询用户
     *
     * @param name
     * @param code
     * @param phone
     * @return
     */
    List<User> findByNameLikeOrCodeLikeOrPhoneLike(String name, String code, String phone);

    /**
     * 分页家条件查询用户列表
     *
     * @param name
     * @param code
     * @param phone
     * @param pageable
     * @return
     */
    Page<User> findByNameLikeOrCodeLikeOrPhoneLike(String name, String code, String phone, Pageable pageable);

    /**
     * 根据条件查询用户数量
     *
     * @param name
     * @param code
     * @param phone
     * @return
     */
    Long countByNameLikeOrCodeLikeOrPhoneLike(String name, String code, String phone);

}
